package com.example.bilibili_miaosha.controller;


import com.example.bilibili_miaosha.entity.User;
import com.example.bilibili_miaosha.service.IOrderService;
import com.example.bilibili_miaosha.vo.OrderDetailVo;
import com.example.bilibili_miaosha.vo.RespBean;
import com.example.bilibili_miaosha.vo.RespBeanEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * 弓川hello mybatisplus
 * </p>
 *
 * @author gongchuan
 * @since 2022-04-01
 */
@Controller
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IOrderService orderService;


    @RequestMapping("detail")
    @ResponseBody
    public RespBean detail(User user, Long orderId){
        if (user == null) {
            return RespBean.error(RespBeanEnum.ACCESS_LIMIT_REAHCED);
        }

        OrderDetailVo detail = orderService.detail(orderId);
        detail.setGoodsImg(detail.getGoodsVo().getGoodsImg());
        return RespBean.success(detail);
    }

}
